import React from 'react'
import './home.less'

class Home extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            flag: false
        }
    }

    componentWillUpdate() {
        console.log(999);
    }

    componentDidMount() {
        // console.log(this.getDOMNode());
        console.log(this.props);
    }

    componentWillReceiveProps() {
    }

    shouldComponentUpdate() {
        alert(222);
    }

    componentWillUnmount(){
        // alert(666);
    }

    renderList() {
        var list = [1,2,3,4,5];
        return list.map((v,i) => <li key={i}>{v}</li>);
    }

    render() {
        let button = null;

        if(this.state.flag){
            button = <button onClick={() => this.show()}>确定</button>;
        }else {
            button = <button onClick={() => this.show()}>取消</button>;
        }

        return (
            <div className='home-wrap'>
                <span>hello I am Michael{this.state.flag ? 1 : 2}</span>
                <div className='img'><img src="/images/md.jpg" /></div>
                {button}
                <div>
                    {alert(999)}
                </div>
            </div>          
        )
    }
}

export default Home